package com.ruibang.glass.portal.service;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.portal.domain.ProductLineReq;
import com.ruibang.glass.portal.entity.ProductLine;
import com.ruibang.glass.portal.mapper.ProductLineMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-15  19:10
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Service
public class ProductLineService extends ServiceImpl<ProductLineMapper, ProductLine> implements IService<ProductLine> {

    public Page<ProductLine> queryProductLine(ProductLineReq productLineReq) {
        return baseMapper.queryProductLine(new Page<>(productLineReq.getPageNo(), productLineReq.getPageSize()), productLineReq);
    }

    public List<ProductLine> getProductLineList(String workshopId) {
        if (StringUtils.isNotBlank(workshopId)) {
            return lambdaQuery().eq(ProductLine::getWorkshopId, workshopId).orderByAsc(ProductLine::getSort).list();
        }
        return lambdaQuery().list();
    }

}
